﻿using System;
using System.Collections.Generic;
using System.Linq;
using Driver;
using MarketDataAnalyzer;
using NUnit.Framework;

namespace Tests.Unit
{
    [TestFixture]
    public class WhenProducingOutput
    {
        private const int NumberOfNewsIdFields = 2;
        private const int NumberOfTimeSamples = 6;
        private const int OnePriceAtEvent = 1;
        [Test]
        public void CsvFilesHaveProperCommas()
        {
            const int numberOfFields = NumberOfNewsIdFields + OnePriceAtEvent + NumberOfTimeSamples + NumberOfTimeSamples;
            const int numberOfCommas = numberOfFields - 1;

            var output = OutputUtilities.ConvertAnalysesToCsv( new List<PriceAnalysis> {new PriceAnalysis()} );
            Assert.That(output.Where(x => x == ',').Count(), Is.EqualTo( numberOfCommas )  );
            Assert.That(output.Split(new []{","}, StringSplitOptions.None).Length, Is.EqualTo( numberOfFields )  );
        }
    }
}
